
#Shibboleth's settings model:
#
# => field's mapping between
# => enabled/disabled
# => ..
module Shibboleth

  def self.enabled
    Shibboleth.settings['enabled'] == 'true'
  end
  
  def self.enabled?
    Shibboleth.settings['enabled'] == 'true'
  end
  
  def self.settings
    Settings::instance
  end

  def self.settings=(value)      
    Settings::instance = value
  end
    
  
  class Settings
  
    @@_settings = nil
 
    def self.store
      Shibboleth.root('config', 'settings', 'shibboleth.yml')
    end
  
    def self.instance
      if @@_settings != nil
        return @@_settings
      end
      @@_settings = YAML::load(File.open(store)) || {}
    end

    def self.instance=(value)
      #result = instance
      #result.update value
      result = value
    
      File.open(store, 'w') do |f|
        f.write(YAML::dump(result))
      end
      @@_settings = result;
    end
  
  end
  
end